﻿IF EXISTS (SELECT * FROM sysobjects WHERE type = 'P' AND name = 'PRC_TB_USER_TASK_HISTORY_CHANGE_REQUEST_MOTIVATION_DE')
	BEGIN
		DROP  Procedure  dbo.PRC_TB_USER_TASK_HISTORY_CHANGE_REQUEST_MOTIVATION_DE
	END

GO

CREATE Procedure dbo.PRC_TB_USER_TASK_HISTORY_CHANGE_REQUEST_MOTIVATION_DE
	(
		@TUHM_HISTORY_ID INT,
		@TUHM_CHANGE_REQUEST_MOTIVATION_ID INT = NULL
	)
AS

DELETE TB_USER_TASK_HISTORY_CHANGE_REQUEST_MOTIVATION
WHERE TUHM_HISTORY_ID = @TUHM_HISTORY_ID AND
(@TUHM_CHANGE_REQUEST_MOTIVATION_ID IS NULL OR TUHM_CHANGE_REQUEST_MOTIVATION_ID = @TUHM_CHANGE_REQUEST_MOTIVATION_ID)

GO

GRANT EXEC ON dbo.PRC_TB_USER_TASK_HISTORY_CHANGE_REQUEST_MOTIVATION_DE TO PUBLIC

GO

